class code4_2 {
    //大根堆
    public int[] inventoryManagement(int[] nums, int k) {
        PriorityQueue<Integer> heap = new PriorityQueue<>((o1,o2)->o2-o1);
        int[] ret = new int[k];
        for(int num:nums) {
            heap.add(num);
            if(heap.size()>k) {
                heap.poll();
            }
        }
        int i = 0;
        for(int e:heap) {
            ret[i++] = e;
        }
        return ret;
    }
}